package com.springboot.cloud.demos.feign.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.AlbumForm;
import com.springboot.cloud.demos.entity.po.User;
import com.springboot.cloud.demos.feign.service.AlbumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
public class AlbumController extends BaseController {

    @Autowired
    private AlbumService albumService;


    @RequestMapping(value = "/album", method = RequestMethod.POST)
    public Result save(HttpServletRequest request, @RequestBody AlbumForm albumForm) {
        User user = getUser(request);
        albumForm.setUserId(user.getId());
        return albumService.save(albumForm);
    }

    @RequestMapping(value = "/open/album/{id}", method = RequestMethod.GET)
    public Result get(@PathVariable String id) {
        return albumService.get(id);
    }

    @RequestMapping(value = "/open/getAlbum", method = RequestMethod.GET)
    public Result getOpenAlbum( String momentId) {
        return albumService.getAlbum( momentId);
    }

}
